<template>
  <div id="TraineeManagement">
    <div class="navbar-search">
      <el-input
      placeholder="请输入姓名,如果不更新,点击右侧搜索按钮"
      v-model="input"
      clearable>
    </el-input>
    <el-button type="primary" class="iconfont icon-sousuo sstub" ></el-button>
    <el-button type="primary" @click="xdw">添加项目</el-button>
    </div>
    <div class="banji">
      <p class="bj">请选择班级：</p>
      <el-select v-model="value" clearable placeholder="请选择">
        <el-option
          v-for="item in options"
          :key="item.value"
          :label="item.label"
          :value="item.value">
        </el-option>
      </el-select>
    </div>
    <div id="chakan">
      <div class="pilsc">
        <el-button type="danger" icon="el-icon-delete" >批量删除</el-button>
        <el-button @click="toggleSelection">{{flag ?'全选':'取消'}}</el-button>
        <el-button class="excel">
         <i class="iconfont icon-icon-excel"></i>
         导出excel数据</el-button>
      </div>
       
         
      <el-table
        ref="multipleTable"
        v-loading="loading"
        :data="tableData"
        tooltip-effect="dark"
        style="width: 100%"
        @selection-change="handleSelectionChange">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column
          label="头像"
          width="80">
          <template slot-scope="scope">
              <!-- <el-avatar shape="square" :size="50" :src="scope.row.headimgurl"></el-avatar> -->
              <el-image 
                style="width: 50px; height: 50px"
                :src="scope.row.headimgurl"
                :preview-src-list="srcList">
              </el-image>
          </template>
        </el-table-column>
        <el-table-column
          prop="name"
          label="姓名"
          width="120">
        </el-table-column>
        <el-table-column
          prop="degree"
          label="学历"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="class"
          label="班级"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="productUrl"
          label="项目"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          prop="cTime"
          label="创建时间"
          show-overflow-tooltip>
        </el-table-column>
        <el-table-column
          label="操作"
          show-overflow-tooltip>
          <el-button type="primary" class="iconfont icon-icon">编辑</el-button>
          <el-button type="success" class="iconfont icon-chakan2">查看</el-button>
          <el-button type="danger" class="iconfont icon-shanchu">删除</el-button>
        </el-table-column>
      </el-table>
      <div class="block">
        <el-pagination background
          hidden-on-single-page
          :page-size="dataCount"
          layout="prev, pager, next"
          :total="total">
        </el-pagination>
      </div>
      <!-- dialog弹出框 -->
      
    </div>
  </div>
</template>
<script>
  import * as api from "../../../../api"
  export default {
    data() {
      return {
        input: '',
        value: '',
        tableData:[],
        options:[],
        headimgList:{},
        params: {
          class:"",
          count: 5
        },
        dataPage:"", //页码
        dataCount: 5, //每页展示的数量
        total: 0, //总共的数据条数
        classOptions: [], 
        disabled: false,
        // 表格的数据对象
        stuData: [],
        flag: true,
        // 表格的加载动画控制
        loading: true,
        classes:"",
        searchList: [],
        searchvalue: "",
        list: [],
          url: 'https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg',
        srcList: [],
        asd:{}
      }
    },
    created() {
      this.getStuList()//获取学员列表的数据
    },
    methods: {
      // 获取表格数据
      getStuList(params = {count:10,page:1,classes:""}) {
        // 发送请求获取学员数据
        api.getStuListApi()
        .then(res => {
          this.tableData = res.data.data
          this.loading = false;
           this.tableData.forEach(item=>{
              if(item.headimgurl) {
                this.srcList.push(item.headimgurl)
              }
          })
        })
      },
      toggleSelection() {
        // 判断批量删除按钮
        this.flag=!this.flag
          this.$refs.multipleTable.toggleAllSelection();
      },
      handleSelectionChange(val) {
        this.multipleSelection = val;
      },
      xdw() {
         
      }

    },
  }
</script>

<style scoped lang='less'>
#TraineeManagement {
  float: left;
  text-align: left;
  padding: 20px;
}

.excel {
  float: right;
  margin: 10px 50px;
}

.pilsc{
  margin-top: 20px;
}

.el-table {
margin-top: 20px;
}

.block {
  margin-top: 10px;
  text-align: center;
}

/deep/ .el-table__empty-block {
  width: 100% !important;
  margin: 10px 0;
}

/deep/ .el-table__header {
  width: 100% !important;
}

/deep/ .el-table__body {
  width: 100% !important;
}



.navbar-search {
  width: 400px;
  display: flex;
}

.sstub {
  
  display: inline-block;
}

.sstub:active {
  background: turquoise;
}

.banji {
  display: flex;
  align-items: center;
  margin-top: 30px;
}

</style>